package my.oschina.net.design.observer.javautil;

import java.util.Observable;
import java.util.Observer;

import my.oschina.net.design.observer.owndesign.Display;

public class CurrentConditionDisplay implements Observer, Display{

	private float temp;
	private float humidity;
	private float pressure;
	
	private Observable observable;
	
	public CurrentConditionDisplay(Observable observable)
	{
		this.observable = observable;
		observable.addObserver(this);
		
	}
	
	@Override
	public void update(Observable o, Object arg) {
		// TODO Auto-generated method stub
		if(o instanceof WeatherData)
		{
			WeatherData weatherdata = (WeatherData)o;
			this.temp = weatherdata.getTemp();
			this.humidity = weatherdata.getHumidity();
			this.pressure = weatherdata.getPressure();
		}
		
		display();
		
	}

	@Override
	public void display() {
		// TODO Auto-generated method stub
		System.out.println("Temp --> " + temp + "humidity --> " +humidity + "pressure -->" + pressure);
	}

}
